import request from '@/utils/request'
import { condition } from '@/utils/request'

export function listCategory(query) {
  return request({
    url: '/mall/category/list',
    method: 'post',
    params: {...query,...{ condition: encodeURI(JSON.stringify([{
    col: 'level',
    rule: 'eq',
    val: 'L1'
  }])) }}
  })
}

export function listCatL1() {
  return request({
    url: '/mall/category/list',
    method: 'post',
    params: { condition: encodeURI(JSON.stringify([{
      col: 'level',
      rule: 'eq',
      val: 'L1'
    }])) }
  })
}

export function listSb() {
  return request({
    url: '/mall/category/list',
    method: 'post',
    params: { condition: condition(['pid', 'eq', '108']) }
  })
}
export function listNc() {
  return request({
    url: '/mall/category/list',
    method: 'post',
    params: { condition: condition(['pid', 'eq', '115']) }
  })
}

export function createCategory(data) {
  return request({
    url: '/mall/category/add',
    method: 'post',
    data
  })
}

export function readCategory(data) {
  return request({
    url: '/mall/category/read',
    method: 'get',
    data
  })
}

export function updateCategory(data) {
  return request({
    url: '/mall/category/edit',
    method: 'post',
    data
  })
}

export function deleteCategory(data) {
  return request({
    url: '/mall/category/remove',
    method: 'post',
    params: data
  })
}
